<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //使用解构语法赋值提高效率
        // let arr = ["后盾人", "2010"];
        // let name = arr[0];
        // let year = arr[1];
        // console.log(name, year);
        // let [name, year] = arr;
        // "use strict"
        // 严格模式报错
        // [name, year] = ["后盾人", "2010"]; 加上let 或者其他
        // console.log(name, year);

        // const [...arr] = "hdcms";
        // console.log(arr);

        //使用 ‘，’站位
        // let [, year] = ["后盾人", "2010"];
        // console.log(year);

        // let [name, ...args] = ["aaa", "后盾人", "2010"];
        // console.log(args);
        // let a = ["tyyy", ...args];
        // console.log(a);

        //默认值
        // let [name, year = 2010] = ["wfj"];
        // console.log(year);

        function show([...args]) {
            // console.log(args);
            console.log(args);
        }

        show(["后盾人", "2010"]);

        function* fibs() {
            let a = 0;
            let b = 1;
            while (true) {
                yield a;
                [a, b] = [b, a + b];
            }
        }

        let [first, second, third, fourth, fifth, sixth] = fibs();
        sixth // 5
    </script>
</body>

</html>